<template>
  <input @keyup.ctrl.alt.s="keyEvent" />
  <button @click.right.prevent="rightClickEvent">只有按右键才触发事件</button>
  <button @mousedown.middle="rightClickEvent">只有按中键才触发事件</button>
  <button @mouseup.left="rightClickEvent">只有按左键才触发事件</button>
</template>

<script lang="ts">
import { reactive, ref } from "vue";
export default {
  setup() {
    function keyEvent(e) {
      console.log("key:" + e.key, "code:" + e.code, "keyCode:" + e.keyCode);
      return false;
    }

    function rightClickEvent(e) {
      console.log("您点击了", e);
      console.log(["左", "中", "右"][e.button] + "键被点击");
    }

    return { keyEvent, rightClickEvent };
  },
};
</script>
<style scoped></style>
